package su.mysrpingbootprojects.hibernatedemo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Класс StudentService
 * <p/>
 * Сервис нашего тестового проекта
 * <p/>
 *
 * @author petr.mikhailin
 * created 10.05.2024 16:09
 */
@Service
public class StudentService {

    private final StudentRepository studentRepository;

    @Autowired
    public StudentService(StudentRepository studentRepository) {
        this.studentRepository = studentRepository;
    }

    public void fillStudentTable() {
        Student studentOne = new Student(1, "Седайко Стюмчик", 19);
        Student studentTwo = new Student(2, "Семарь Здрахарь", 21);
        Student studentThree = new Student(3, "Навотно Стоечка", 20);
        studentRepository.addNewStudent(studentOne);
        studentRepository.addNewStudent(studentTwo);
        studentRepository.addNewStudent(studentThree);
    }

    public List<Student> getStudentsList() {
        return studentRepository.getAllStudents();
    }

}
